package c.c.b.a.a;

import c.b.a.a.a;
import java.io.IOException;
import java.io.OutputStream;

/* compiled from: Okio */
public final class n implements v {
    public final /* synthetic */ x a;
    public final /* synthetic */ OutputStream b;

    public n(x xVar, OutputStream outputStream) {
        this.a = xVar;
        this.b = outputStream;
    }

    public x a() {
        return this.a;
    }

    public void close() throws IOException {
        this.b.close();
    }

    public void flush() throws IOException {
        this.b.flush();
    }

    public void g0(e eVar, long j) throws IOException {
        y.a(eVar.b, 0, j);
        while (j > 0) {
            this.a.g();
            s sVar = eVar.a;
            int min = (int) Math.min(j, (long) (sVar.c - sVar.b));
            this.b.write(sVar.a, sVar.b, min);
            int i = sVar.b + min;
            sVar.b = i;
            long j2 = (long) min;
            j -= j2;
            eVar.b -= j2;
            if (i == sVar.c) {
                eVar.a = sVar.d();
                t.b(sVar);
            }
        }
    }

    public String toString() {
        StringBuilder g = a.g("sink(");
        g.append(this.b);
        g.append(")");
        return g.toString();
    }
}
